from tortoise.models import Model
from tortoise import fields

class User(Model):
    id = fields.IntField(pk=True)
    username = fields.CharField(max_length=50, unique=True)
    email = fields.CharField(max_length=100, index=True)
    # 新增手机号字段（允许为空，长度11位）
    phone = fields.CharField(max_length=11, null=True, description="手机号")  # 🆕 新增字段
    created_at = fields.DatetimeField(auto_now_add=True)
    is_active = fields.BooleanField(default=True)

    class Meta:
        table = "users"  # 自定义表名

    def __str__(self):
        return self.username